<!DOCTYPE html>
<html><head>
	    <meta charset="utf-8">
    <title>ThinkPHP5.0</title>

    <meta name="description" content="Dashboard">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--Basic Styles-->
    <link href="__ADMIN__/style/bootstrap.css" rel="stylesheet">
    <link href="__ADMIN__/style/font-awesome.css" rel="stylesheet">
    <link href="__ADMIN__/style/weather-icons.css" rel="stylesheet">

    <!--Beyond styles-->
    <link id="beyond-link" href="__ADMIN__/style/beyond.css" rel="stylesheet" type="text/css">
    <link href="__ADMIN__/style/demo.css" rel="stylesheet">
    <link href="__ADMIN__/style/typicons.css" rel="stylesheet">
    <link href="__ADMIN__/style/animate.css" rel="stylesheet">
    <style type="text/css">
        .open{
            border:1px solid #ccc;
            padding: 0 3px 0 3px;
            cursor: pointer;
        }
    </style>
</head>
<body>
	<!-- 头部 -->
	{include file="Common/head"}
	<!-- /头部 -->
	
	<div class="main-container container-fluid">
		<div class="page-container">
			<!-- Page Sidebar -->
            {include file="Common/left"}
            <!-- /Page Sidebar -->
            <!-- Page Content -->
            <div class="page-content">
                <!-- Page Breadcrumb -->
                <div class="page-breadcrumbs">
                    <ul class="breadcrumb">
                                        <li>
                        <a href="{:url('index/index')}">系统</a>
                    </li>
                                        <li><a href="{:url('cate/lst')}">栏目管理</a></li>
                                        <li class="active">栏目列表</li>
                                        </ul>
                </div>
                <!-- /Page Breadcrumb -->

                <!-- Page Body -->
                <div class="page-body">
                    
<button type="button" tooltip="添加栏目" class="btn btn-sm btn-azure btn-addon" onClick="javascript:window.location.href = '{:url('add')}'"> <i class="fa fa-plus"></i> Add
</button>
<div class="row">
    <div class="col-lg-12 col-sm-12 col-xs-12">
        <div class="widget">
            <div class="widget-body">
                <div class="flip-scroll">
                    <form method="post" action="{:url('cate/del_sort')}" >
                    <table class="table table-bordered table-hover">
                        <thead class="">
                            <tr pid="0">
                                <th class="text-center" width="6%">伸缩</th>
                                <th class="text-center" width="6%">
                                    <label>
                                        <input id="checkall" class="colored-blue" type="checkbox">
                                        <span class="text"></span>
                                    </label>
                                </th>
                                <th class="text-center" width="8%">ID</th>
                                <th>栏目</th>
                                <th class="text-center" width="10%">状态</th>
                                <th class="text-center" width="10%">属性</th>
                                <th class="text-center" width="10%">所属模型</th>
                                <th class="text-center" width="2%">排序</th>
                                <th class="text-center" width="12%">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            {volist name="cateRes" id="cate"}
                            <tr id="{$cate.id}" pid="{$cate.pid}">
                                <td align="center"><span class="open">+</span></td>
                                <td align="center">
                                    <label>
                                        <input  name="itm[]"  class="colored-blue" value="{$cate.id}" type="checkbox">
                                        <span class="text"></span>
                                    </label>
                                </td>
                                <td align="center">{$cate.id}</td>
                                <td class="c{$i}"><span class="fh"></span><span><?php echo str_repeat('-', $cate['level']*8);?></span><a href="{:url('Content/lst',['cate_id'=>$cate['id'],'model_id'=>$cate['model_id']])}" class="cate" pid="{$cate.pid}"><b>{$cate.cate_name}</b></a>
                                <a style="float:right;" class="btn btn-sm btn-azure btn-addon" href="{:url('add',array('cateid'=>$cate['id']))}"><i class="fa fa-plus"></i>添加子栏目</a>
                                </td>
                                <td align="center"><a cateid="{$cate.id}" onclick="changestatus(this);" {if condition="$cate['status'] eq 1"} class="btn btn-primary btn-sm shiny" {else/} class="btn btn-danger btn-sm shiny" {/if} >{if condition="$cate['status'] eq 1"}显示{else/}隐藏{/if}</a></td>
                                <td align="center">{if condition="$cate['cate_attr'] eq 1"}列表栏目{else /}频道封面{/if}</td>
                                <td align="center">{$cate.model_name}</td>
                                <td align="center"><input name="sort[{$cate.id}]" style="width:50px; text-align:center;" type="text" value="{$cate.sort}"></td>
                                <td align="center">
                                    <a href="{:url('edit',array('cateid'=>$cate['id']))}" class="btn btn-primary btn-sm shiny">
                                        <i class="fa fa-edit"></i> 编辑
                                    </a>
                                    <a href="#" onClick="warning('确实要删除吗', '{:url('cate/del',array('cateid'=>$cate['id']))}')" class="btn btn-danger btn-sm shiny">
                                        <i class="fa fa-trash-o"></i> 删除
                                    </a>
                                </td>
                            </tr>
                            {/volist}
                            <tr>
                            <td colspan="8"></td>
                            <td align="center">
                                <button class="btn btn-default" type="submit">保存信息</button>
                            </td>
                            </tr>
                        </tbody>
                    </table>
                    </form>
                </div>
                <div>
                	                </div>
            </div>
        </div>
    </div>
</div>

                </div>
                <!-- /Page Body -->
            </div>
            <!-- /Page Content -->
		</div>	
	</div>

	    <!--Basic Scripts-->
    <script src="__ADMIN__/style/jquery_002.js"></script>
    <script src="__ADMIN__/style/bootstrap.js"></script>
    <!--Beyond Scripts-->
    <script src="__ADMIN__/style/beyond.js"></script>
    <script type="text/javascript">
    //栏目伸缩状态js
    $('tr[pid!=0]').hide();
    $('.open').click(function(){
        var id=$(this).parents('tr').attr('id');
        if($(this).text()=='+'){
            $(this).text('-');
            $('tr[pid='+id+']').show();
        }else{
            $(this).text('+');
            // $('tr[pid='+id+']').hide();
            $.ajax({
            type:"post",
            dataType:"json",
            data:{cateid:id},
            url:"{:url('Cate/ajaxlst')}",
            success:function(data){
                // alert(typeof(data));
                var sonids=[];
                var idsobj=$('tr[pid!=0]');
                idsobj.each(function(k,v){
                    sonids.push($(this).attr('id'));
                });
                $.each(data,function(k,v){
                    if($.inArray(v,sonids)){
                        $('tr[id='+v+']').hide();
                        $('tr[id='+v+']').find('span:first').text('+');
                    }
                });
            }
        });
        }
    });
    //ajax异步修改栏目显示状态
    function changestatus(o){
        var cateid=$(o).attr("cateid");
        $.ajax({
            type:"post",
            dataType:"json",
            data:{cateid:cateid},
            url:"{:url('Cate/changestatus')}",
            success:function(data){
                if(data==1){
                    $(o).attr("class","btn btn-danger btn-sm shiny");
                    $(o).text('隐藏');
                }else{
                    $(o).attr("class","btn btn-primary btn-sm shiny");
                    $(o).text('显示');
                }
            }
        });
    }

    //全选处理
    $("#checkall").click(function(){
        if($("#checkall").attr("checked")){
            $(".colored-blue").removeAttr("checked");
        }else{
            $(".colored-blue").attr("checked","checked");
        }
    });

    
    </script>
</body></html>